
	<!DOCTYPE html>
	<html>
		<head>
			<meta charset="UTF-8">
			<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
			<title>发货列表</title>
			<link rel="stylesheet" href="css/AllStyle.css" />
			<link rel="stylesheet" href="css/iconfont.css" />
			<script type="text/javascript" src="js/common.js" ></script>
			<script type="text/javascript" src="js/companydata.js" ></script>
			  <!-- <script type="text/javascript" src="js/loadData.js" ></script> -->
			<script type="text/javascript" src="js/data.js" ></script>
			<script type="text/javascript" src="js/tmpl.js" ></script>
			<script type="text/javascript" src="js/ch.js" ></script>
			<script type="text/javascript" src="js/template.js" ></script>
		</head>
		<body>
			<!-- 页头 -->
			<section>
				<script type="text/javascript">
					AllPageHeader()
				</script>
			</section>

			<section class="AllContent" id="AllContent" style="background-color: #fff;">

				<form>
					<div class="FormStyle">
						<div class="ScanInput" style="width:90%;margin:10px auto;">
							<p style="margin: 0px;"><input name="taskNo" id="taskNo" class="bg-focus form-control" type="text" placeholder="工程编码,工序编码,工程名称,工序名称,质检编号"></p>
							<p style="margin: 0px;"><button type="button" style="font-size:0.9em" onclick="querySend();">查询</button></p>
						</div>
						<p class="TheResults" style="margin:0px 5%;padding:0px;padding-bottom:10px;"></p>
						<div class=""><p class="relative alert alert-success"></p></div>
					</div>

					<div class="grid-body" id="cententbody"></div>
				</form>

				<div id="sendList" style="background-color: #fff;">
					<img style="width: 40%;margin:20px auto;display: block;" src="images/loading5.gif">
				</div>

			</section>

			<div id="dddd"></div>
		</body>
		<script type="text/javascript" src="js/jquery.min.js" ></script>
		<script type="text/javascript" src="js/mui.min.js" ></script>
		<script type="text/javascript">
			mui.init();
			$('.AllHeader li:eq(1)').text("报工列表");
			$('.AllHeader li:eq(2)').html('<img style="width:28px" src="images/Scan.png">')

			mui.plusReady(function(){
				//扫描器
				document.getElementById('Scanner').addEventListener('tap', function() {
				  mui.openWindow({
					url: 'Scanner.html?etk=2',
					id:'Scanner.html'
				  });
				});
			});

			//添加refresh自定义事件监听
			window.addEventListener('qualityList',function(){
				var id = event.detail.id;
				$('#taskNo').val(id);
				querySend();
			});

			//搜索客户发货单
			$(".serarchBtn").on('tap',function(){
			  querySend();
			});
			mui.back = function() {
			    mui.openWindow({
			    	url: 'procList.html',
			    	id:'procList.html'
			    });
			}
			mui.plusReady(function(){
				//扫描器
				document.getElementById('Scanner').addEventListener('tap', function() {
				  mui.openWindow({
					url: 'Scanner.html?etk=2',
					id:'Scanner.html'
				  });
				});
			});

			//添加refresh自定义事件监听
			window.addEventListener('taskList',function(){
				var id = event.detail.id;
				$('#taskNo').val(id);
				querySend();
			});
			$(function(){
				if(getCookie("token") === null || getCookie("token") === ''){
					window.location.href='login.html';
					return;
				}
				$.ajax({
					headers:{
						"X-Access-Token":getCookie("token")
					},
					type: "GET",
					url: getServerUrl()+"/task/findByProcId/"+$_GET['procId'], //与此php页
					dataType: 'json', //从php返回的值以 JSON方式 解释
					contentType: 'application/json',
					data: 'pageSize=20'+'&pageNo=1', //
					success: function (json) {//如果调用php成功
						sendlist = json.result.records;
						var chtml = '';
						//var chtml = '';
						if (!empty(sendlist)) {
							for (var i = 0; i < sendlist.length; i++) {
								if (!empty(sendlist[i])) {
									chtml = chtml + '<a href="reporting.html?taskId=' + sendlist[i].id  +
											'&procId='+ $_GET['procId'] +
											'&engineCode='+ sendlist[i].engineCode +
											'&engineName='+ sendlist[i].engineName +
											'&taskNo='+ sendlist[i].taskNo +
											'&procCode='+ sendlist[i].procCode +
											'&procName='+ sendlist[i].procName +
											'&taskCount='+ sendlist[i].taskCount +
											'&inProcCount='+ sendlist[i].inProcCount +
											'&reportCount='+ sendlist[i].reportCount +
											'">';
									chtml = chtml + '<div class="ProductsListContent">';
									chtml = chtml + '<div class="ProductsDetails">';
									chtml = chtml + '<p>项目编号：' + sendlist[i].engineCode + '</p>';
									chtml = chtml + '<p>工程名称：' + sendlist[i].engineName + '</p>';
									chtml = chtml + '<p>任务单号：' + sendlist[i].taskNo + '</p>';
									chtml = chtml + '<p>工序代码：' + sendlist[i].procCode + '</p>';
									chtml = chtml + '<p>工序名称：' + sendlist[i].procName + '</p>';
									chtml = chtml + '<p>任务数量：' + sendlist[i].taskCount + '</p>';
									chtml = chtml + '<p>在制数量：' + sendlist[i].inProcCount + '</p>';
									chtml = chtml + '<p>已报数量：' + sendlist[i].reportCount + '</p>';
									chtml = chtml + '<span style="width: 100%;padding-top:10px;height:40px;margin-top:10px;background-color:#00a9ed;float:left;color:#ffffff;text-align:center;font-size:20px;">报工</span>';
									// chtml = chtml + '<p>工序名称：' + sendlist[i].name + '</p>';
									chtml = chtml + '</li>';
									chtml = chtml + '</ul>';
									chtml = chtml + '</div>';
									chtml = chtml + '</div>';
									chtml = chtml + '</a>';


								}
							}
						}
						$("#sendList").html(chtml);
						showpage(json.total_results,json.page_no,json.page_size,getwindowhref());
					}
					// error:function(json){
					// 	window.location.href='login.html';
					// }
				});
				var RequestTime=1,page_no=1,cishu=1,intZh=1,ptinfo=1;
				$("#AllContent").scroll(function(){
					var divHeight = $(this).height();
					var nScrollHeight = $(this)[0].scrollHeight;
					var nScrollTop = $(this)[0].scrollTop;
					var xiami = nScrollTop + divHeight;
					if(nScrollTop + divHeight >= nScrollHeight) {

						if(page_no == 1){
							var Pages = 2;
						}else{
							Pages = ++page_no
						}

						if(RequestTime == cishu){
							$('#sendList').append("<img id='LoadingImg' style='borderTop:3px solid #f3f3f3;width: 20%;margin:0px auto;display: block;' src='images/loading5.gif'><p style='text-align:center;color:#777;padding:0px 0px;'>正在加载...</p>");
							$(this).animate({scrollTop:xiami},800);
							RequestTime++;
							$.ajax({
								headers:{
									"X-Access-Token":getCookie("token")
								},
								type: "GET",
								url: getServerUrl()+"/procedure/proc/list", //与此php页
								dataType: 'json', //从php返回的值以 JSON方式 解释
								contentType: 'application/json',
								data: 'pageSize=20'+'&pageNo='+Pages, //
								success: function (json) {//如果调用php成功
									sendlist = json.result.records;
									var ZLength = json.total/20;
									if(ZLength<1){
										RequestTime = 0;
										// console.log(ZLength);
										return false;
									}
									UpwardRefresh(sendlist);
									showpage(json.total,0,20,getwindowhref());
									page_no = 0;
									cishu = 0;
									var ZLength = json.total/20;
									var Strlength = ZLength.toString();

									if(Strlength.substring(1)){
										intZh = Strlength.substring(0,1);
										console.log(intZh);
										intZh++;

									}
									if(0> ZLength){
										RequestTime = 0;
									}

								},
								error:function(json){
									alertMessage(json.errordescription);
								}
							});
						}else if(RequestTime == 0){
							if(ptinfo == 1){
								$('#sendList').append("<img id='LoadingImg' style='borderTop:3px solid #f3f3f3;width: 20%;margin:0px auto;display: block;' src='images/loading5.gif'><p style='text-align:center;color:#777;padding:0px 0px;'>正在加载...</p>");
								$(this).animate({scrollTop:xiami},800);

								setTimeout(function () {
									$('#LoadingImg').attr('src','images/loading5_.jpg');
									$('#LoadingImg').next().text('没有更多数据...');
								}, 1500);

								setTimeout(function () {
									$('#LoadingImg').next().hide(500);
									$('#LoadingImg').hide(500);
								}, 2500);

								ptinfo++;
							}
						}

					}
				});

			})

			function querySend() {
				var taskNo= $("#taskNo").val();
				var myData = {'pageSize':20,'pageNo':1};
				if(taskNo !== undefined && taskNo !== ''){
					myData = {'taskNo':taskNo,'pageSize':20,'pageNo':1}
				}
				$.ajax({
					headers:{
						"X-Access-Token":getCookie("token")
					},
					type: "GET",
					url: getServerUrl()+"/task/findByProcId/"+$_GET['procId'], //与此php页
					dataType: 'json', //从php返回的值以 JSON方式 解释
					contentType: 'application/json',
					data: myData, //
					success: function (json) {//如果调用php成功
						sendlist = json.result.records;
						var chtml = '';
						//var chtml = '';
						if (!empty(sendlist)) {
							for (var i = 0; i < sendlist.length; i++) {
								if (!empty(sendlist[i])) {
									chtml = chtml + '<a href="reporting.html?taskId=' + sendlist[i].id  +
											'&procId='+ $_GET['procId'] +
											'&engineCode='+ sendlist[i].engineCode +
											'&engineName='+ sendlist[i].engineName +
											'&taskNo='+ sendlist[i].taskNo +
											'&procCode='+ sendlist[i].procCode +
											'&procName='+ sendlist[i].procName +
											'&taskCount='+ sendlist[i].taskCount +
											'&inProcCount='+ sendlist[i].inProcCount +
											'&reportCount='+ sendlist[i].reportCount +
											'">';
									chtml = chtml + '<div class="ProductsListContent">';
									chtml = chtml + '<div class="ProductsDetails">';
									chtml = chtml + '<p>项目编号：' + sendlist[i].engineCode + '</p>';
									chtml = chtml + '<p>工程名称：' + sendlist[i].engineName + '</p>';
									chtml = chtml + '<p>任务单号：' + sendlist[i].taskNo + '</p>';
									chtml = chtml + '<p>工序代码：' + sendlist[i].procCode + '</p>';
									chtml = chtml + '<p>工序名称：' + sendlist[i].procName + '</p>';
									chtml = chtml + '<p>任务数量：' + sendlist[i].taskCount + '</p>';
									chtml = chtml + '<p>在制数量：' + sendlist[i].inProcCount + '</p>';
									chtml = chtml + '<p>已报数量：' + sendlist[i].reportCount + '</p>';
									chtml = chtml + '<span style="width: 100%;padding-top:10px;height:40px;margin-top:10px;background-color:#00a9ed;float:left;color:#ffffff;text-align:center;font-size:20px;">报工</span>';
									// chtml = chtml + '<p>工序名称：' + sendlist[i].name + '</p>';
									chtml = chtml + '</li>';
									chtml = chtml + '</ul>';
									chtml = chtml + '</div>';
									chtml = chtml + '</div>';
									chtml = chtml + '</a>';


								}
							}
						}
						$("#sendList").html(chtml);
						showpage(json.total_results,json.page_no,json.page_size,getwindowhref());
					}
					// error:function(json){
					// 	window.location.href='login.html';
					// }
				});
			}

			function UpwardRefresh(sendList) {
				var chtml = '';
				//var chtml = '';
				if (!empty(sendList)) {
					for (var i = 0; i < sendList.length; i++) {
						if (!empty(sendlist[i])) {
							chtml = chtml + '<div class="ProductsListContent">';
							chtml = chtml + '<div class="ProductsDetails">';
							chtml = chtml + '<p>工序单号：' + sendList[i].code + '</p>';
							chtml = chtml + '<p>工序名称：' + sendList[i].name + '</p>';
							chtml = chtml + '</li>';
							chtml = chtml + '</ul>';
							chtml = chtml + '</div>';

							chtml = chtml + '<div class="moreOperation">';
							chtml = chtml + '<p><a href="taskList.html?id=' + sendList[i].id + '" >报工</a></p>';
							chtml = chtml + '</div>';
							chtml = chtml + '</div>';
						}
					}
				}
				$('#LoadingImg').next().remove();
				$('#LoadingImg').remove();
				$("#sendList").append(chtml);
			}

		</script>
		<style>
			p{
				margin-top: 10px;
			}
		</style>
	</html>
